package cn.tedu.system.oa.stamp.dao.repository;

import cn.tedu.system.oa.stamp.pojo.entity.Stamp;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.data.redis.core.ValueOperations;
import org.springframework.stereotype.Repository;

import java.util.List;
@Repository
@Slf4j
public class StampCacheRepository {
    /**
     * 用于redis 缓存
     */
    @Autowired
    private RedisTemplate<String, List<Stamp>> redisTemplate;

    public List<Stamp> getAllStamp() {
        ValueOperations<String,List<Stamp>> stringOperations = redisTemplate.opsForValue();
        String stampKey = "Stamp_KEY";
        return stringOperations.get(stampKey);
    }


    public void saveAllStamp(List<Stamp> list) {
        String stampKey = "Stamp_KEY";
        redisTemplate.opsForValue().set(stampKey,list);
    }

}
